package br.com.simulador.vo;

import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import org.apache.commons.beanutils.BeanUtils;
import org.jboss.seam.annotations.Name;

import br.com.simulador.model.ItemQuestao;
import br.com.simulador.model.Questao;
@Name("questaoVO")
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class QuestaoVO implements Serializable {
	@XmlTransient
	private Questao questao;
	


	private Long id;
	
	private byte[] descricao;
	@XmlElementWrapper(name="tags")                                                                          
	@XmlElement(name="tag")

	private List<TagVO> tags = new ArrayList<TagVO>();
	
	@XmlElementWrapper(name="itens")                                                                          
	@XmlElement(name="item")	
	private List<ItemQuestaoVO> listQuestoes=new ArrayList<ItemQuestaoVO>();
	public QuestaoVO(Questao questao) {
		this.questao = questao;
		
		try {
			BeanUtils.copyProperties(this, this.questao);
			for(ItemQuestao item : this.questao.getListItemQuestoes()){
				this.getListQuestoes().add(new ItemQuestaoVO(item));
			}
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public byte[] getDescricao() {
		return descricao;
	}
	public void setDescricao(byte[] descricao) {
		this.descricao = descricao;
	}

	public List<ItemQuestaoVO> getListQuestoes() {
		return listQuestoes;
	}
	public void setListQuestoes(List<ItemQuestaoVO> listQuestoes) {
		this.listQuestoes = listQuestoes;
	}
	public QuestaoVO() {
		super();
		// TODO Auto-generated constructor stub
	}

}
